import { ref } from 'vue'
import { defineStore } from 'pinia'

export const useUserStore = defineStore('user', () => {
    // state
    const userInfo = ref()
    //获取admin信息
    const getUserInfo = ()=> { 
        return userInfo.value
    }
    const setUserInfo = (user) => {
        userInfo.value = user
    }
    const clearUserInfo = ()=>{
        userInfo.value = ''
    }
    return {
        userInfo,
        getUserInfo,
        setUserInfo,
        clearUserInfo,
    }  
}
,
{
    // 网页端的配置
    // persist: true,
    // 小程序端的配置
    persist: {
      storage: {
        getItem: (key) => uni.getStorageSync(key),
        setItem: (key, value) => uni.setStorageSync(key, value)
      },
    },
},

)